package com.oa.oaspcpersonalcenter.controller;




import com.oa.oaspccommon.po.Salary;
import com.oa.oaspcpersonalcenter.service.SalaryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author Sdx
 * 2021-04-15
 */
@RestController
public class SalaryController {
    @Autowired
    private SalaryService salaryService;

    @RequestMapping(value = "/salarys", method = RequestMethod.GET)
    public List<Salary> findSalarys() {
        List<Salary> salarys = salaryService.findSalarys();
        return salarys;
    }

    @RequestMapping(value = "/salary/{uid}&{sid}", method = RequestMethod.GET)
    public Salary findSalaryByUidAndSid(@PathVariable("uid") int uid, @PathVariable("sid") double sid) {
        Salary salary = salaryService.findSalaryByUidAndSid(uid, sid);
        return salary;
    }

    @RequestMapping(value = "/salary", method = RequestMethod.POST)
    public boolean addSalary(@RequestBody Salary salary) {

        boolean b = salaryService.addSalary(salary);
        return b;
    }

    @RequestMapping(value = "/salary", method = RequestMethod.PUT)
    public boolean updateSalary(@RequestBody Salary salary) {
        boolean b = salaryService.updateSalary(salary);
        return b;
    }

    @RequestMapping(value = "/salary", method = RequestMethod.DELETE)
    public boolean deleteSalaryByUidAndSid(@RequestParam(value = "uid") int uid, @RequestParam(value = "sid") double sid) {
        boolean b = salaryService.deleteSalaryByUidAndSid(uid, sid);
        return b;
    }

}
